

CalendarService = Packages.com.google.gdata.client.calendar.CalendarService;
gdata           = Packages.com.google.gdata.data;

function main( ui ) { 

    var service = new CalendarService("demo-calendar-1");
    
    var username = "@gmail.com";
    var password = "*****";
    service.setUserCredentials(username, password);
    try {
    
        var calendar = new gdata.calendar.CalendarEntry();
        calendar.setTitle(new gdata.PlainTextConstruct("CMC"));
        calendar.setSummary(new gdata.PlainTextConstruct("CMC TEST CALENDAR"));
        //calendar.setTimeZone(new gdata.calendar.TimeZoneProperty("Italy/Los_Angeles"));
        calendar.setHidden( gdata.calendar.HiddenProperty.FALSE);
        calendar.setColor(new gdata.calendar.ColorProperty("#2952A3"));
        calendar.addLocation(new gdata.extensions.Where("","","Napoli"));

        // Insert the calendar
        var postUrl = new java.net.URL("https://www.google.com/calendar/feeds/default/owncalendars/full");
        var returnedCalendar = service.insert(postUrl, calendar);

    }
    catch( e ) {
    
        return e;
    }
    
    return "OK";

}